<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>

<body>
	<form action="" method="POST">
		<input type="text" name='data'>
		<input type="submit" value="提交">
	</form>
	<script>
		var form = document.forms[0];
		form.addEventListener('submit', function () {
			alert('表单已被提交')
		})
	</script>
</body>

</html>